import { reactive } from 'vue';

const state = reactive({
  user: null,  // 用于存储用户信息，包括权限信息
  isAuthenticated: false,  // 用于指示用户是否已经认证
});

const login = (user) => {
  state.user = user;
  state.isAuthenticated = !!user;
};

const logout = () => {
  state.user = null;
  state.isAuthenticated = false;
};

const useAuth = () => {
  return {
    state,
    login,
    logout,
  };
};

export default useAuth;
